blob: 681913112f0c86e7a50ce6269df0f981548dc9c8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { auth, get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function load({ cookies, params, parent }) {
const { user } = await parent();
const aid = cookies.get("aid");
const { address } = params;
const { balance } = await get(`/account/${aid}`, auth(cookies));
try {
const invoice = await get(`/invoice/${address}`);
if (invoice) {
const recipient = await get(`/users/${invoice.uid}`);
if (recipient?.id !== user.id)
redirect(307, `/pay/${recipient.username}`);
}
} catch (e) {
// invoice not found
}
return { balance };
}
|